home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 286_01 / environ.c < prev    next >
Text File  |  1989-05-23  |  2KB  |  94 lines

  1. #include <stdio.h>
  2. #include <gds.h>
  3. #include <GRADENV.h>
  4.  
  5. #define MAX_ENVSLOT 10 
  6.  
  7. struct grad_env {
  8.     int status;
  9.     int winx1, winy1, winx2, winy2;
  10.     int orgx, orgy;
  11.     int style, plottype, frame_nu, font_nu;
  12. };
  13.  
  14. static struct grad_env ENV_STACK[MAX_ENVSLOT]= {
  15.   { PERMANENT, 0, 0, MAX_XSCN, MAX_YSCN, 0, 0, 0xffff, 0, 0, 0 }
  16. };
  17.  
  18. EnvSave(slot_nu)
  19. int slot_nu;
  20. {
  21.     register struct grad_env *ptr;
  22.  
  23.     if ((slot_nu<0) || (slot_nu>=MAX_ENVSLOT)) {
  24.         graderror(2,1,slot_nu);
  25.         slot_nu=0;
  26.     }
  27.     if (slot_nu==0) {
  28.         if ((slot_nu=find_envs())<=0) return(0); 
  29.     }
  30.     ptr=&ENV_STACK[slot_nu];
  31.     ptr->status=USED;
  32.     ptr->winx1=WINX1;
  33.     ptr->winy1=WINY1;
  34.     ptr->winx2=WINX2;
  35.     ptr->winy2=WINY2;
  36.     ptr->orgx=ORGX;
  37.     ptr->orgy=ORGY;
  38.     ptr->style=STYLE;
  39.     ptr->plottype=CUR_PLOT;
  40.     ptr->frame_nu=CUR_FRAME;
  41.     ptr->font_nu=CURFONT;
  42.     return(slot_nu);
  43. }
  44.  
  45. static find_envs()
  46. {
  47.     register int loop;
  48.  
  49.     for (loop=1; loop<MAX_ENVSLOT; loop++) {
  50.         if (ENV_STACK[loop].status==NOT_USED)
  51.             return(loop);
  52.     }
  53.     return(-1);
  54. }
  55.  
  56. EnvRsto(slot_nu,flag)
  57. unsigned int slot_nu;
  58. register unsigned flag;
  59. {
  60.     register struct grad_env *ptr;
  61.  
  62.     
  63.     if ((slot_nu>=MAX_ENVSLOT)) {
  64.         graderror(4,2,slot_nu);
  65.     }
  66.     ptr=&ENV_STACK[slot_nu];
  67.     if (ptr->status == NOT_USED) {
  68.         graderror(2,3,slot_nu);
  69.     }
  70.     if (!(flag & KEEP_FRAME)) {
  71.         SelectFrame(ptr->frame_nu);
  72.     }
  73.     if (!(flag & KEEP_WIN)) {
  74.         SetWin(ptr->winx1-ORGX, ptr->winy1-ORGY,
  75.                ptr->winx2-ORGX, ptr->winy2-ORGY);
  76.     }
  77.     if (!(flag & KEEP_ORG)) {
  78.         SetOrg(ptr->orgx,ptr->orgy);
  79.     }
  80.     if (!(flag & KEEP_STYLE)) {
  81.         SetStyle(ptr->style);
  82.     }
  83.     if (!(flag & KEEP_PLOTTYPE)) {
  84.         PlotType(ptr->plottype);
  85.     }
  86.     if (!(flag & KEEP_FONT)) {
  87.         SelectFont(ptr->font_nu);
  88.     }
  89.     if (!(flag & KEEP_SLOT) && (ptr->status != PERMANENT)) {
  90.         ptr->status=NOT_USED;
  91.     }
  92. }
  93.  
  94.